#include "internal.h"

/*
 * Priority of the task has changed. This may cause
 * us to initiate a push or pull.
 */
static void prio_changed_rt(struct rq *rq, struct task_struct *p, int oldprio)
{
    if (!task_on_rq_queued(p))
        return;

    if (task_current_donor(rq, p))
    {
        /*
         * If our priority decreases while running, we
         * may need to pull tasks to this runqueue.
         */
        if (oldprio < p->prio)
            rt_queue_pull_task(rq);

        /*
         * If there's a higher priority task waiting to run
         * then reschedule.
         */
        if (p->prio > rq->rt.highest_prio.curr)
            resched_curr(rq);
    }
    else
    {
        /*
         * This task is not running, but if it is
         * greater than the current running task
         * then reschedule.
         */
        if (p->prio < rq->donor->prio)
            resched_curr(rq);
    }
}
